from django.db import models
from django.contrib.auth.models import User

# Create your models here.

class BodyType(models.Model):
    id = models.AutoField(primary_key=True)
    body_type = models.CharField(max_length=20)  # Field name made lowercase.
    analysis = models.JSONField() # {module:;text:;}
    symptoms = models.JSONField()
    risk = models.JSONField()
    diet = models.JSONField()
    acupoint = models.JSONField()
    acupoint_images = models.JSONField()
    created = models.DateTimeField(auto_now_add=True) # 记录创建时间
    updated = models.DateTimeField(null=True, auto_now=True)  # updated默认null，如果有更新，自动更新为当前时间

    class Meta:
        # managed = False
        db_table = 'report_bodytype'

class Report(models.Model):
    id = models.AutoField(primary_key=True)
    report_id = models.CharField(max_length=128)
    createTime = models.DateTimeField()  # 报告检测时间
    user = models.ForeignKey(User, models.PROTECT)
    age = models.IntegerField(default=0)
    body_type = models.ForeignKey(BodyType, models.PROTECT)
    type_stat = models.JSONField(max_length=120)
    height = models.FloatField(default=0.0) # 单位 cm
    weight = models.FloatField(default=0.0) # 单位 kg
    faceImg = models.TextField()
    tongueImg = models.TextField()
    created = models.DateTimeField(auto_now_add=True) # 记录创建时间

    class Meta:
        # managed = False
        db_table = 'report_report'